//
//  JFSocketDataParserHelper.m
//  JFBase
//
//  Created by Alan Wang on 2018/11/22.
//  Copyright © 2018 Alan Wang. All rights reserved.
//

#import "JFSocketDataParserHelper.h"

@implementation JFSocketDataParserHelper

+(JFSocketResultVo*)heartbeat:(NSString*)baseUrl{
    return [[JFSocketResultVo alloc] init];
}
//连接成功后会调用
+(JFSocketResultVo*)didConnect:(NSString*)baseUrl{
    JFSocketResultVo * data= [[JFSocketResultVo alloc] init];
    NSString * hello = @"hello Python";
    NSData * dataStr = [hello dataUsingEncoding:NSUTF8StringEncoding];
    data.data = dataStr;
    data.readType = DataReadType_Length;
    data.length = 12;
    data.actionType = DataParserActionType_ReadWrite;
    return data;
}
//收到数据会调用
+(JFSocketResultVo*)dataParser:(NSString*)baseUrl data:(NSData*)data  dataParserType:(DataParserType)type withTag:(NSInteger)tag{
    NSString * str  = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
    JFSocketResultVo * ResultVo = [[JFSocketResultVo alloc] init];
    NSMutableDictionary *result = [[NSMutableDictionary alloc] init];
    result[@"data"] = str;
    ResultVo.actionType = DataParserActionType_Complete;
    ResultVo.errorNo = 0;
    ResultVo.results = result;
    return ResultVo;
}

//发送数据转化二进制方法
+(JFSocketResultVo*)dataParser:(NSString*)baseUrl data:(id)data  dataParserType:(DataParserType)type{
    NSData *datatemp = [NSJSONSerialization dataWithJSONObject:data options:NSJSONWritingPrettyPrinted error:nil];
    JFSocketResultVo * data2= [[JFSocketResultVo alloc] init];
    data2.data = datatemp;
    data2.actionType = DataParserActionType_Write;
    return data2;
}
@end
